<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<title>Insert title here</title>
<script type="text/javascript" src="../js/jquery-3.1.0.min.js"></script>
<script type="text/javascript">
var currentPage = ${currentPage};
var totalPage = ${totalPage};
$(document).ready(function(){
	$(":button:eq(1)").click(function(){
		location.href="roleadd.jsp";
	});
	$(".page:first").click(function(){
		currentPage = 1;
		getList();
	});
	$(".page:eq(1)").click(function(){
		if(currentPage==1){
			alert("当前已经是第一页啦");
		}else{
			currentPage--;
			getList();
		}
	});
	$(".page:eq(2)").click(function(){
		if(currentPage==totalPage){
			alert("当前已经是最后一页啦");
		}else{
			currentPage++;
			getList();
		}
	});
	$(".page:eq(3)").click(function(){
		currentPage = totalPage;
		getList();
	});
	$(":button:first").click(function(){
		currentPage = 1;
		getList();
	});
	function getList(){
		var namekey = $("#namekey").val();
		location.href="GetRoleListServlet?currentPage="+currentPage+"&namekey="+namekey;
	}
});
function del(id){
	if(confirm("是否确定删除？")){
		location.href="DelRoleServlet?id="+id+"&currentPage="+currentPage;
	}
}
function update(id,name){
	location.href="roleadd.jsp?id="+id+"&name="+name;
}
function manager(id){
	location.href="GetMenuListByRole?id="+id;
}
</script>
</head>
<body>
菜单名称：<input type="text" id="namekey" value="${param.namekey}">
<input type="button" value="搜索">
<input type="button" value="添加">
<table border="1" width="80%">
	<tr><th>ID</th><th>角色名称</th><th>操作</th></tr>
	<c:forEach items="${list}" var="b">
		<tr>
			<td>${b.roleId}</td>
			<td>${b.roleName}</td>
			<td>
				<input type="button" value="删除" onclick="del(${b.roleId})">
				<input type="button" value="修改" onclick="update(${b.roleId},'${b.roleName}')">
				<input type="button" value="权限管理" onclick="manager(${b.roleId})">
			</td>
		</tr>
	</c:forEach>
</table>
<input type="button" value="第一页" class="page">
<input type="button" value="上一页" class="page">
<input type="button" value="下一页" class="page">
<input type="button" value="最后页" class="page">
${currentPage}/${totalPage}
</body>
</html>